import { drawImageOption, queryDrawImageOption } from "../validate/ai";
import { Application } from "egg";

export default (app: Application) => {
  const { jwt } = app;

  return {
    'api.token': {
      path: '/api/ai/token',
      method: 'GET',
      options: {
        tags: ['ai/token'],
        description: 'apiToken',
        handler: app.controller.ai.getToken,
        middlewares: [jwt],
      }
    },
    'api.ai.draw': {
      path: '/api/ai/draw/img',
      method: 'POST',
      options: {
        tags: ['ai/draw/img'],
        description: 'api.ai.draw',
        handler: app.controller.ai.drawImage,
        middlewares: [jwt],
        validate: drawImageOption
      }
    },
    'api.ai.query': {
      path: '/api/ai/draw/query',
      method: 'POST',
      options: {
        tags: ['ai/draw/query'],
        description: 'api.ai.query',
        handler: app.controller.ai.queryImage,
        middlewares: [jwt],
        validate: queryDrawImageOption
      }
    },
    'api.ai.ket.sign': {
      path: '/api/ai/sign/ket',
      method: 'GET',
      options: {
        tags: ['ai/draw/ket'],
        description: 'api.ai.ket',
        handler: app.controller.ai.getKetParam,
        middlewares: [jwt],
      }
    },
    'api.ai.ali.video': {
      path: '/api/ai/video/create',
      method: 'POST',
      options: {
        tags: ['ai/video/create'],
        description: 'ai.ali.video',
        handler: app.controller.ai.createVideos,
        middlewares: [jwt],
      }
    },
    'api.ai.ali.query': {
      path: '/api/ai/video/query',
      method: 'GET',
      options: {
        tags: ['ai/video/query'],
        description: 'ai.ali.query',
        handler: app.controller.ai.getVideoResult,
        middlewares: [jwt],
      }
    }
  }
}